<?php

/**
 * This is the model class for table "sys_stockist".
 *
 * The followings are the available columns in table 'sys_stockist':
 * @property string $stockist_network_id
 * @property string $stockist_name
 * @property string $stockist_address
 * @property string $stockist_city_id
 * @property string $stockist_state_id
 * @property string $stockist_country_id
 * @property string $stockist_zipcode
 * @property string $stockist_phone
 * @property string $stockist_fax
 * @property string $stockist_mobilephone
 * @property string $stockist_input_datetime
 * @property string $stockist_is_active
 *
 * The followings are the available model relations:
 * @property SysNetwork $stockistNetwork
 */
class sys_stockist extends CActiveRecord {

    /**
     * Returns the static model of the specified AR class.
     * @return sys_stockist the static model class
     */
    public static function model($className=__CLASS__) {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName() {
        return 'sys_stockist';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules() {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('stockist_network_id, stockist_city_id, stockist_state_id, stockist_country_id', 'length', 'max' => 10),
            array('stockist_name, stockist_zipcode, stockist_phone, stockist_fax, stockist_mobilephone', 'length', 'max' => 255),
            array('stockist_is_active', 'length', 'max' => 1),
            array('stockist_address, stockist_input_datetime', 'safe'),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('stockist_network_id, stockist_name, stockist_address, stockist_city_id, stockist_state_id, stockist_country_id, stockist_zipcode, stockist_phone, stockist_fax, stockist_mobilephone, stockist_input_datetime, stockist_is_active', 'safe', 'on' => 'search'),
        );
    }

    /**
     * @return array relational rules.
     */
    public function relations() {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
            'rel_stockist_to_network' => array(self::BELONGS_TO, 'sys_network', 'stockist_network_id'),
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels() {
        return array(
            'stockist_network_id' => 'Stockist Network',
            'stockist_name' => 'Stockist Name',
            'stockist_address' => 'Stockist Address',
            'stockist_city_id' => 'Stockist City',
            'stockist_state_id' => 'Stockist State',
            'stockist_country_id' => 'Stockist Country',
            'stockist_zipcode' => 'Stockist Zipcode',
            'stockist_phone' => 'Stockist Phone',
            'stockist_fax' => 'Stockist Fax',
            'stockist_mobilephone' => 'Stockist Mobilephone',
            'stockist_input_datetime' => 'Stockist Input Datetime',
            'stockist_is_active' => 'Stockist Is Active',
        );
    }

    /**
     * Retrieves a list of models based on the current search/filter conditions.
     * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
     */
    public function search() {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.

        $criteria = new CDbCriteria;

        $criteria->compare('stockist_network_id', $this->stockist_network_id, true);
        $criteria->compare('stockist_name', $this->stockist_name, true);
        $criteria->compare('stockist_address', $this->stockist_address, true);
        $criteria->compare('stockist_city_id', $this->stockist_city_id, true);
        $criteria->compare('stockist_state_id', $this->stockist_state_id, true);
        $criteria->compare('stockist_country_id', $this->stockist_country_id, true);
        $criteria->compare('stockist_zipcode', $this->stockist_zipcode, true);
        $criteria->compare('stockist_phone', $this->stockist_phone, true);
        $criteria->compare('stockist_fax', $this->stockist_fax, true);
        $criteria->compare('stockist_mobilephone', $this->stockist_mobilephone, true);
        $criteria->compare('stockist_input_datetime', $this->stockist_input_datetime, true);
        $criteria->compare('stockist_is_active', $this->stockist_is_active, true);

        return new CActiveDataProvider($this, array(
            'criteria' => $criteria,
        ));
    }

}